<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta name="Keywords" content="网站关键词">
    <meta name="Description" content="网站介绍">
    <link rel="stylesheet" href="./css/base.css">
    <link rel="stylesheet" href="./css/iconfont.css">
    <link rel="stylesheet" href="./css/reg.css">
    <style>
    	#logo{
    		width: 147px; height: 100px;
    		z-index:999;
			position:fixed; left:0px; top:0px;
    	}
    </style>
</head>
<body>
	<div id="logo">
		<a href="homePage.jsp"><img src="images/bj2.png" /> </a>
	</div>
    <div id="ajax-hook"></div>
	    <div class="wrap">
	        <div class="wpn">
	            <div class="form-data pos" style="top: 30px; padding-top: 50px;">
	                <!--<a href=""><img src="./img/login3.png" class="head-logo"></a>-->
	              <!--  <a href=""><img src="./img/logo.png" class="head-logo"></a>-->
	                <form action="addUser.do" method="post" id="isnoFrom">
	                <p class="tel-warn hide"><i class="icon-warn"></i></p>
	                    <p class="p-input pos">
	                        <label for="tel">用户名</label>
	                        <input type="text" id="username" name="u_name" onblur="isNoUser()"  autocomplete="off"><!--type="number"  -->
	                  		<span id="msg1"></span><br />	
	                    </p>
	                    <p class="p-input pos" >
	                        <label>输入密码</label>
	                       <!--  <input type="password"/> -->
	                        <input type="password" name="pwd" id="pwd" onblur="isNoPwd()">
	                   		<span id="msg2"></span><br /> 
	                    </p>
	                    <p class="p-input pos">
	                        <select name="u_sex" >
	                        	<option>男</option>
	                        	<option>女</option>
	                        </select>
	                       <!--  <span class="tel-warn pwd-err hide"><em></em><i class="icon-warn" style="margin-left: 5px"></i></span> -->
	                    </p>
	                    
	                    <p class="p-input pos">
	                        <label>输入电话号码</label>
	                        <span id="msg3"></span><br />
	                        <input type="text" name="phone" id="phone" onblur="isNoPh()">
	                    </p>
	                    <p class="p-input pos">
	                        <label>输入邮箱地址</label>
	                        <span id="msg4"></span><br />	
	                        <input type="text" name="email"  id="email" onblur="isNoEmail()">
	                    
	                    </p>
	                    
	                    <p class="p-input pos" id="sendcode">
	                        <label>输入验证码</label>
	                        <input type="number" id="yzm1" name="yzm">
	                        <a href="#" class="send" id="yzm">发送验证码</a>
	                        <span class="time " ><em>120</em>s</span><!-- hide -->
	                    </p>
	                    <p class="p-input pos" id="pwd">
	                        <label>输入住址</label>
	                        <input type="text" name="address">
	                        <span class="tel-warn pwd-err hide"><em></em><i class="icon-warn" style="margin-left: 5px"></i></span>
	                    </p>
	                </form>
	                <div class="reg_checkboxline pos">
	                    <span class="z"><i class="icon-ok-sign boxcol" nullmsg="请同意!"></i></span>
	                    <input type="hidden" name="agree" value="1">
	                    <div class="Validform_checktip"></div>
	                    <p>我已阅读并接受 <a href="xieyi.jsp" target="_brack">《好易贷借款协议》</a></p>
	                </div>
	                <button class="lang-btn" onclick="isNoSub()" id="sub">注册</button>
	                <div class="bottom-info">已有账号，<a href="./index.jsp">马上登录</a></div>
	                <p class="right">Powered by © 2018</p>
	            </div>
	        </div>
	    </div>
    </form>
   <script src="./js/jquery2.js"></script>
    <script src="./js/agree.js"></script>
   <!--   <script src="./js/reg.js"></script> -->
    <!--  -->
<script type="text/javascript">
			var a = false;
			var b = false;
			var c = false;
			var d = false;
			//验证用户名
			function isNoUser(){
				var  username = /^[0-9a-zA-Z]{4,10}$/; 
				var yh = $("#username").val();
			       if(!username.test(yh)){
			    	   $("#msg1").html("用户名格式有误!!!");
						$("#msg1").css("color","red");
// 						$("#un").css("display","block");
			       }else{
			    	   $.ajax({
			    		   url:"isUser.do",
				   			data:{"u_name":$("#username").val()},
				   			type:"post",
				   			dataType:"json",
				   			success:function(data){
				   				if(data.mss){
				   					alert(data.mss);
// 				   					$("#msg1").css("display","block");
				   					$("#msg1").html("用户名已经存在!!!");
				   					$("#msg1").css("color","red");
			   					}else{
			   						$("#msg1").html("✔ 输入正确");
			   						$("#msg1").css("color","green");
			   					}
				   			}
				   		});
						a = true;
			       }
			}
			
			
			
			//验证密码
			function isNoPwd(){  
				var password = /^[a-zA-Z0-9]{6,6}$/; //长度为6,必须中英文组合
				var yhmm = $("#pwd").val();
			       if(!password.test(yhmm)){
			    	   $("#msg2").html("密码格式有误!!!");
					   $("#msg2").css("color","red"); 
			       }else{
			    	   $("#msg2").html("✔ 输入正确");
					   $("#msg2").css("color","green");
						b = true;
			       }
			}
			
			 //验证手机号码
			function isNoPh(){  
				var phone = /^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$/; 
				var yhnm = $("#phone").val();
			       if(!phone.test(yhnm)){
			    	   $("#msg3").html("手机格式有误!!!");
						$("#msg3").css("color","red"); 
			       }else{
			    	   $("#msg3").html("✔ 输入正确");
						$("#msg3").css("color","green");
						c = true;
			       }
			}
			
// 			//验证邮箱  
 			function isNoEmail(){  
				var email = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; 
				var yhnm = $("#email").val();
			       if(!email.test(yhnm)){
			    	   $("#msg4").html("邮箱格式有误!!!");
						$("#msg4").css("color","red"); 
			       }else{
			    	   $("#msg4").html("✔ 输入正确");
						$("#msg4").css("color","green");
						d = true;
			       }
			}
			
			
			
			
			function isNoSub(){  
				if(a==true && b==true && c==true && d==true ){
					$("#isnoFrom").submit();
				}else{
					alert("注册信息有误!");
				}
			}
			
			
			
	/* 发送验证码 */		
			$(function(){
				$("#yzm").click(function(){
					$.ajax({
						data:{"phone":$("#phone").val()},
						type:"post",
						url:"message.do",
						dataType:"json",
						cache:false,//缓存
						success:function(data){
							
					},
						error:function(){
							alert("失败");
						}
					});
				});
			});
</script>




</body>
</html>